package com.example.test;

import com.example.test.fragment.LoginFragment;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class LoginActivity extends BaseActivity {


	private SharedPreferences sp;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		mTintManager.setStatusBarTintEnabled(true);
		mTintManager.setStatusBarTintResource(R.color.darkwhite);
		setContentView(R.layout.activity_loginac);
		ViewUtils.inject(this);
		if(checkLogin()){
			Intent intent=new Intent(this, MainActivity.class);
			startActivity(intent);
			this.finish();
		}else{
			
			init();
		}

	}

	private boolean checkLogin() {
		// TODO Auto-generated method stub
		sp = getSharedPreferences("user", MODE_PRIVATE);
		boolean islogin=sp.getBoolean("login", false);
		return islogin;
	}

	private void init() {
		// TODO Auto-generated method stub
	
		ActivityControler.addAcitvity(this);
		LoginFragment fragment = new LoginFragment();
		getSupportFragmentManager().beginTransaction()
				.replace(R.id.content_frame, fragment, "login").commit();
	}
	
}
